<?php 
   require_once 'config.php';
   $data = getValue('data','arr','POST','');
   $album_name = getValue('album','str','POST','');
   $alb_id = getValue('alb_id','int','POST',0);
   $cat_id = getValue('cat_id','int','POST',0);
   $link_profile = getValue('profile','str','POST','');
   if($album_name != ''){
      $sql_insert = "INSERT INTO 
                        xinh_albums(name,
                                    link_profile,
                                    date,
                                    cat_id)
                        VALUES('" . $album_name . "','" 
                                  . $link_profile . "'," 
                                  . time() . "," . $cat_id . ")";
                        echo $sql_insert;
      $db_exe = new db_execute_return();
      $alb_id = $db_exe->db_execute($sql_insert);
   }
   $value_insert = "VALUES";
   foreach($data as $value){
      $value_insert .= "('" . $value . "'," . $alb_id . ",". time() . "),";
   }
   $value_insert = substr($value_insert,0,-1);
   $sql_insert_image = "INSERT INTO 
                           xinh_images(link,alb_id,date)
                           " . $value_insert;
   $db_exe_image = new db_execute($sql_insert_image);
   $rows_inserted = $db_exe_image->rows_affected;
   $db_exe        = new db_execute("UPDATE 
                                       xinh_albums 
                                    SET 
                                       total_images = total_images + " . $rows_inserted . "
                                    WHERE id =" . $alb_id) ;
   unset($db_exe);
   unset($db_exe_image);
   
?>